package com.gopay.common.user.dao.impl;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.domain.cust.CustBankAcctInfo;
import com.gopay.common.user.dao.CustBankAcctInfoDAO;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ClassName: CustBankAcctInfoDAOImpl
 * @Description: (这里用一句话描述这个类的作用)
 * @Author: tianxin
 * @Date: 2017/12/7 16:57 www.gopay.com.cn Inc.All rights reserved.
 */
@Repository("commonCustBankAcctInfoDAO")
public class CustBankAcctInfoDAOImpl extends BaseDAOImpl<CustBankAcctInfo, Long> implements CustBankAcctInfoDAO {

    @Override
    public List<CustBankAcctInfo> getCustBankAcctInfoList(String custId) {
        DetachedCriteria criteria = DetachedCriteria.forClass(CustBankAcctInfo.class);
        criteria.add(Restrictions.eq("custId", custId));
        criteria.add(Restrictions.eq("delFlag", 0));
        List<CustBankAcctInfo> list = this.findByCriteria(criteria);
        return list.size() > 0 ? list : null;
    }

    @Override
    public void updateCustBankAcctInfo(CustBankAcctInfo info) {
        if (info != null) {
            this.update(info);
        }
    }

    @Override
    public CustBankAcctInfo getCustBankAcctInfo(String custId) {
        return getCustBankAcctInfoList(custId).get(0);
    }
}
